I have a simple question regarding slicing of a numpy array.
First let's define a numpy array.
<pre class='prettyprint lang-py'>
import numpy as np
arr = np.arange(9).reshape(3,3)
</pre>
Now let's do some slicing:
<pre class='prettyprint lang-py'>
print(arr[2].shape)
print(arr[2,:].shape)
</pre>
We get the same result in both cases.
<pre class='prettyprint lang-py'>
(3,)
</pre>
Why is the result different when I change the indexing?
<pre class='prettyprint lang-py'>
print(arr[2:,:].shape)
(1,3)
</pre>
Thank you very much!
You must be logged in to post. Please login or register an account.